import { Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { AuthModule } from './auth/auth.module';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { HeroesModule } from './heroes/heroes.module';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { InMemoryDataService } from './in-memory-data.service';



import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientInMemoryWebApiModule, InMemoryDbService } from 'angular-in-memory-web-api';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ComposeMessageComponent } from './compose-message/compose-message.component';


@NgModule({
  declarations: [
    AppComponent,
    PageNotFoundComponent,
    ComposeMessageComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    HeroesModule,
    AuthModule,
    AppRoutingModule,
    // 内存网络API模块，用来模拟服务请求与响应，包含内存数据服务，后面那个是数据封装，暂时不要
    HttpClientInMemoryWebApiModule.forRoot(
      InMemoryDataService, { dataEncapsulation: false }
    )
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {

    // 检查路由器的配置是否正确
    constructor(router: Router){
      // 正常显示路由中的函数
      const replacer = (key: any, value: any) => (typeof value === 'function') ? value.name : value;
      // 2为缩进两字符并自动换行
      console.log('Routes: ', JSON.stringify(router.config, replacer, 2));
    }
}
